package com.virtualightning.mvvm.tools

import android.os.Handler
import java.util.concurrent.Executor

/**
 *  Anchor : Create by CimZzz
 *  Time : 2021/12/24 11:25
 *  Handler 线程执行器
 */
class HandlerThreadExecutor(
	/**
	 * 所依附的 Handler
	 */
	private val executeHandler: Handler,
): Executor {
	/**
	 * Executes the given command at some time in the future.  The command
	 * may execute in a new thread, in a pooled thread, or in the calling
	 * thread, at the discretion of the `Executor` implementation.
	 */
	override fun execute(command: Runnable?) {
		if(command != null) {
			executeHandler.post(command)
		}
	}
}